<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>统一地图平台</title><link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <style>
        html,
        body,
        #mapui {
            margin: 0 auto;
            width: 100%;
            height: 100%
        }

        html,
        body {
            margin: 0;
            overflow: hidden;
            background: #fff;
            width: 100%;
            height: 100%;
            position: absolute;
            top: 0;
        }
    </style>

</head>

<body>
    <div id="mapui"></div>

    <script src="./js_thematic_map_example/script/jq/jquery.min.js"></script>
    <script src="./js_example/script/map.min.js"></script>

    <script src="./js_example/script/demo.js"></script>

    <script>
        var echartslayer = null
        var option = null;
        var amap = null;
        var that = this;

        $.get('./js_thematic_map_example/data/flights.json', function (data) {

            function getAirportCoord(idx) {
                return [data.airports[idx][3], data.airports[idx][4]];
            }

            var routes = data.routes.map(function (airline) {
                return [
                    getAirportCoord(airline[1]),
                    getAirportCoord(airline[2])
                ];
            });

            option = {
                title: {
                    text: '',
                    left: 'center',
                    textStyle: {
                        color: '#eee'
                    }
                },

                tooltip: {
                    formatter: function (param) {
                        var route = data.routes[param.dataIndex];
                        return data.airports[route[1]][1] + ' > ' + data.airports[route[
                            2]][1];
                    }
                },
                GLMap: {
                    roam: true
                },
                series: [{
                    type: 'lines',
                    coordinateSystem: 'GLMap',
                    data: routes,
                    large: true,
                    largeThreshold: 100,
                    lineStyle: {
                        normal: {
                            opacity: 0.05,
                            width: 0.5,
                            curveness: 0.3
                        }
                    },
                    // 设置混合模式为叠加
                    blendMode: 'lighter'
                }]
            }

            map.Factory.create('mapui', {
                center: [0, 0],
                fullExtent: {
                    xmin: 90.992204,
                    ymin: 10.979711,
                    xmax: 120.5338915,
                    ymax: 50.543712
                },
                zoom: 2,
                projection: 'EPSG:4326',
                strategy: ['mapboxgl', 'openlayers'],
                style: style
            }, (o) => {
                amap = o;
                map.Factory.loadSpecialMap('echarts', () => {
                    that.init(amap.pmap);
                })
            });

        });


        function init(map) {
            echartslayer = new EchartsLayer(map);
            echartslayer.chart.setOption(option);
        }



    </script>
</body>

</html>